<!--Descriptive page name and system messages, descriptions, and instructions.-->
<% if @user %>
<h2><%=h t('.owned_collections', :default => "%{user_name}'s Collections", :user_name => @user.login) %></h2>
<% elsif @collection %>
<h2><%=h t('.listing_sub_collections', :default => "Challenges/Subcollections in %{collection_name}", :collection_name => @collection.title) %></h2>
<% elsif @work %>
<h2><%=h t('.listing_work_collections', :default => "Collections including %{work_name}", :work_name => @work.title) %></h2>
<% else %>
<h2><%=h t('.listing_collections', :default => "Collections in the %{archive_name}", :archive_name => ArchiveConfig.APP_NAME) %></h2>
<% end %>

 <% if @collections.empty? %>
  <%= t('.no_collections_found', :default => "Sorry, there were no collections found.") %>
 <%else %>
  <h2><%= search_header @collections, @query, "Collection" %> </h2>
 <% end %>
 
<!--/descriptions-->
<!--Subnavigation, sorting and actions-->
<div class="navigation module">
<% if logged_in? %>
<h3 class="landmark">Navigation</h3>
<ul class="navigation" role="navigation">
  <% if @user && @user == current_user %>
    <li><%= link_to ts("Manage Collected Works"), user_collection_items_path(@user) %></li>
  <% end %>
  <% if @collection && !@collection.parent && @collection.user_is_maintainer?(current_user) %>
    <li><%= link_to ts("New Subcollection"), new_collection_collection_path(@collection) %></li>
  <% else %>
	  <li><%= link_to ts("See Open Challenges"), list_challenges_collections_path %></li>
	  <li><%= link_to ts("New Collection"), new_collection_path %></li>
	<% end %>
</ul>
<% end %>

<% if @sort_and_filter %> 
<!--sorting subnav-->
  <ul class="sorting navigation" role="navigation">
    <li><h4><%= ts('Sort By') %></h4></li>
    <li><%= sort_link ts('Title'), "collections.title" %></li>
    <li><%= sort_link ts('Date'), "collections.created_at", {:sort_default => true, :desc_default => true} %></li>
    <li><%= sort_link ts('Size'), "item_count", {:desc_default => true} %></li>
  </ul>
<!---/subnav-->
<% end %>
</div>

<% unless @collections.blank? %>
  <!--pagination here-->
  <%= will_paginate @collections, {:previous_label => '&laquo; Previous', :next_label => 'Next &raquo;'} %>

  <!--main content-->
  <h3 class="landmark">List of Collections</h3>
  <ul class="collection picture index<% if @user && current_user == @user %> works-own<% end %>">
  <% @collections.each do |collection| %>
    <%= render :partial => "collection_blurb", :locals => {:collection => collection} %>
  <% end %>
  </ul>
<% end %>

<% if @sort_and_filter %>
<!--filters subnav-->
<%= render :partial => 'collections/filters' %>
<!---/subnav-->
<% end %> 
<div class="clear"><!-- presentational--></div>

<% unless @collections.blank? %>
<%= will_paginate @collections, {:previous_label => '&laquo; Previous', :next_label => 'Next &raquo;'} %>
<% end %>